<div class="form">


<?php $form = $this->beginWidget('GxActiveForm', array(
	'id' => 'alias-tablas-form',
	'enableAjaxValidation' => true,
));
?>

	<p class="note">
		<?php echo Yii::t('app', 'Fields with'); ?> <span class="required">*</span> <?php echo Yii::t('app', 'are required'); ?>.
	</p>

	<?php echo $form->errorSummary($model); ?>
		<div class="row">
		<?php echo $form->labelEx($model,'INI_ALS_ID', array('class'=>'label_info')); ?>
		<?php
                    
                    if(is_numeric($_GET["encuesta_id"]))
                        $encId = $_GET["encuesta_id"];
                    else
                        $encId = $model->ENC_ID;
                    
                    if (!is_numeric($model->ALSTBLID))
                        echo $form->dropDownList($model, 'INI_ALS_ID', GxHtml::listDataEx(Alias::model()->findAll(array('condition'=>'ALSID IN (select als_id from nucleosbasicosalias a join encuestas b on a.nclb_id = b.nclb_id where b.encid=' . $encId . ' and a.als_id not in (select ini_als_id from alias_tablas where enc_id = ' . $encId . ' ) and a.als_id not in (select fin_als_id from alias_tablas where enc_id = ' . $encId . ' ) ) '))), Array('class'=>'Ccombo')); 
                    else
                        echo $form->dropDownList($model, 'INI_ALS_ID', GxHtml::listDataEx(Alias::model()->findAll(array('condition'=>'ALSID = '. $model->INI_ALS_ID .' OR ALSID IN (select als_id from nucleosbasicosalias a join encuestas b on a.nclb_id = b.nclb_id where b.encid=' . $encId . ' and a.als_id not in (select ini_als_id from alias_tablas where enc_id = ' . $encId . ' ) and a.als_id not in (select fin_als_id from alias_tablas where enc_id = ' . $encId . ') ) '))), Array('class'=>'Ccombo')); 
                    ?>
		<?php echo $form->error($model,'INI_ALS_ID'); ?>
		</div><!-- row -->
		<div class="row">
		<?php echo $form->labelEx($model,'FIN_ALS_ID', array('class'=>'label_info')); ?>
		<?php 
                if (!is_numeric($model->ALSTBLID))
                        echo $form->dropDownList($model, 'INI_ALS_ID', GxHtml::listDataEx(Alias::model()->findAll(array('condition'=>'ALSID IN (select als_id from nucleosbasicosalias a join encuestas b on a.nclb_id = b.nclb_id where b.encid=' . $encId . ' and a.als_id not in (select ini_als_id from alias_tablas where enc_id = ' . $encId . ' ) and a.als_id not in (select fin_als_id from alias_tablas where enc_id = ' . $encId . ' ) ) '))), Array('class'=>'Ccombo')); 
                    else
                        echo $form->dropDownList($model, 'INI_ALS_ID', GxHtml::listDataEx(Alias::model()->findAll(array('condition'=>'ALSID = '. $model->FIN_ALS_ID .' OR ALSID IN (select als_id from nucleosbasicosalias a join encuestas b on a.nclb_id = b.nclb_id where b.encid=' . $encId . ' and a.als_id not in (select ini_als_id from alias_tablas where enc_id = ' . $encId . ' ) and a.als_id not in (select fin_als_id from alias_tablas where enc_id = ' . $encId . ') ) '))), Array('class'=>'Ccombo')); 
                ?>
		<?php echo $form->error($model,'FIN_ALS_ID'); ?>
		</div><!-- row -->
		<div class="row">
		<?php echo $form->labelEx($model,'SIMPLE', array('class'=>'label_info','style'=>'float:left;width:20%')); ?>
		<?php echo $form->checkBox($model, 'SIMPLE', array( 'style'=>'float:left;width:70%')); ?>
		<?php echo $form->error($model,'SIMPLE'); ?>
                <div style="clear:both;"></div>
		</div><!-- row -->
                <div class="row">
		<?php echo $form->labelEx($model,'CTFECHACREACION', array('class'=>'label_info')); ?>
		<?php echo $form->textField($model, 'CTFECHACREACION', array('disabled'=>'disabled', 'class'=>'CfechaT')); ?>
		<?php echo $form->error($model,'CTFECHACREACION'); ?>
		</div><!-- row -->
                <div class="row">
		<?php //echo $form->labelEx($model,'ENC_ID'); ?>
		<?php echo CHtml::dropDownList('ENC_ID', $encId, GxHtml::listDataEx(Encuestas::model()->findAllAttributes(null, true)), array('style'=>'display:none')); ?>
		<?php echo $form->error($model,'ENC_ID'); ?>
		</div><!-- row -->
<div class="center-submit">              
<?php
echo GxHtml::submitButton(Yii::t('app', 'Guardar', array('class'=>'add_input')));
$this->endWidget();
?>
</div>
</div><!-- form -->